package inet.app.vod.adapter;

import inet.app.vod.activity.R;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SuggestNewsAdapter extends ArrayAdapter<String> {

	ArrayList<String> mTitles;
	Activity mContext;

	LayoutInflater mInflater;

	public SuggestNewsAdapter(Activity context, int textViewResourceId,
			ArrayList<String> titles) {

		super(context, R.layout.item_listview_fun);
		this.mContext = context;
		this.mInflater = this.mContext.getLayoutInflater();
		this.mTitles = titles;

	}

	@Override
	public int getCount() {
		return mTitles.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		final String title = mTitles.get(position);

		if (convertView == null) {
			convertView = mInflater.inflate(
					R.layout.item_listview_news_suggest, null);
			holder = new ViewHolder();
			holder.mTitle = (TextView) convertView
					.findViewById(R.id.title_text);
			holder.mShaderImg = (ImageView) convertView
					.findViewById(R.id.shader_img);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.mTitle.setText(title);
		holder.mShaderImg.setVisibility((position == 0) ? View.VISIBLE
				: View.GONE);
		return convertView;
	}

	static class ViewHolder {
		public TextView mTitle;
		public ImageView mShaderImg;
	}
}
